<?php

@session_start();

require 'facebook.php';
$facebook = new Facebook(array(
  'appId' => '	286247248145759',
  'secret' => '1180e7d6da9640077c727e3a55cdf5f0',
  'cookie' => 'false'
 ));



$user = $facebook->getUser();
if ($user) {
  try {

    $access_token = $facebook->getAccessToken();
// If the user has been authenticated then proceed
    $user_profile = $facebook->api('/me');
//    $_SESSION['fb_name'] = $fbuser['name'];
//    $_SESSION['fb_id'] = $fbuser['id'];
    $fieldsFriends = array();
    $fieldsFriends['fields']='id,name,picture';
    $_SESSION['fb_friends'] = $facebook->api('/me/friends',$fieldsFriends );
    
    $_SESSION['fb_name'] = $user_profile['name'];
    $_SESSION['fb_id'] = $user_profile['id'];
    $_SESSION['user_name'] = $user_profile['username'];    





?>
    <!DOCTYPE HTML>
    <html style="overflow: hidden;">
      <head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width" />
        <title>Oni -  Dona tu Celebración </title>
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <link rel="stylesheet" type="text/css" href="css/jquery.fancybox.css" />
        <link rel="stylesheet" type="text/css" href="css/home/home.css" />

        <script src="js/modernizr.js"></script>
      </head>
      <body>
      <header></header>
      <div id="main_wrapper">

      <?php require_once 'header.php'; ?>
        
        <div id="card_banner"></div>
        <div id="flag_overlay"></div>

        <div id="main_content">


          <p>
            Diviértete en tu celebración junto a tus amigos mientras ayudan a que muchos niños tengan la oportunidad de vivir y seguir creciendo.
          </p>
          <a href="javascript:;" id="show_steps"></a>
          <a href="nuevo_evento.php" id="create_event"></a>

        </div><!-- END #main_content  -->


      </div> <!-- END #main_wrapper  -->

      <div id="lightbox_wrap" style="display: none;">
        <div id="lightbox_container">
          <div id="table_cont">
            <div id="table_head">


            </div>
          </div>
          <a href="javascript:;" id="btn_close_lightbox"></a>

        </div>

      </div>

      <footer></footer>
      <script src="js/jquery-1.7.2.min.js"></script>
      <script src="js/jquery.fancybox.js"></script>
      <script src="js/home/home.js"></script>
    </body>
    </html>





<?php
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
} else {
  $params = array(
   'client_id' => '286247248145759',
   'scope' => 'publish_stream, user_photos, read_stream, photo_upload, read_friendlists, friends_likes',
   'redirect_uri' => 'http://127.0.0.1/oni/mockup/'
   //'redirect_uri' => 'localhost/oni/mockup/'
  );
  $loginUrl = $facebook->getLoginUrl($params);
  echo '<script>top.location.href = "' . $loginUrl . '";</script>';
}
?>

